package com.hjwoo.app.views;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;

import com.hjwoo.app.R;
import com.hjwoo.app.baseviews.BaseAppCompatActivity;
import com.hjwoo.app.been.OrdersObject;
import com.hjwoo.app.common.AppManager;
import com.hjwoo.app.utils.Utils;

/**
 * Created by renxiaowen on 2016/8/2
 * 预约成功界面
 */
public class AppointmentSuccessActivity extends BaseAppCompatActivity {

    private Button btnBack;
    private Button backMain,order_detial_btn;
    private OrdersObject ordersObject;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_appointment_success);
        Utils.initTitle("预约成功",this, true);
        btnBack = (Button) findViewById(R.id.btnBack);
        backMain = (Button) findViewById(R.id.backMain);
        order_detial_btn= (Button) findViewById(R.id.order_detial_btn);
        Intent intent = getIntent();
        ordersObject = (OrdersObject) intent.getSerializableExtra("order");
        order_detial_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(AppointmentSuccessActivity.this, OrderTrackingActivity.class);
                Bundle mBundle = new Bundle();
                mBundle.putSerializable("order", ordersObject);//传递某个单子的信息
                intent.putExtras(mBundle);
                startActivity(intent);
            }
        });
        //返回上一页
        btnBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               finish();
            }
        });
        //回到首页
        backMain.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AppManager.getAppManager().finishAllActivity();
            }
        });
    }
    //监听手机返回键
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK ){
            finish();
        }
        return super.onKeyDown(keyCode, event);
    }
}
